export default {
  data() {
    return {
      baseUrl: this.$basePageUrl,
      // 品牌映射车系Id
      brandIdToVehicleSeriesId: {},

      showToTop: false,
      disclaimerContent: ""
    };
  },
  // watch: {
  //   brandIdToVehicleSeriesId: {
  //     handler(newV) {
  //       console.log("newVnewVnewVnewVnewVnewVnewVnewVnewVnewVnewVnewV", newV);
  //       if (newV) {
  //         console.log(
  //           ">==brandIdToVehicleSeriesIdbrandIdToVehicleSeriesIdbrandIdToVehicleSeriesIdbrandIdToVehicleSeriesId",
  //           newV
  //         );
  //         var newA = [];
  //         for (const key in this.brandIdToVehicleSeriesId) {
  //           var arr = this.brandIdToVehicleSeriesId[key];
  //           if (Array.isArray(arr)) {
  //             if (arr.length == 1) {
  //               newA.push({
  //                 ...JSON.parse(JSON.stringify(arr[0])),
  //                 id: arr[0].uuid,
  //                 value: arr[0].brandName
  //               });
  //             } else if (arr.length > 1) {
  //               arr
  //                 .filter(item => item.id)
  //                 .map(item => {
  //                   newA.push({
  //                     ...JSON.parse(JSON.stringify(item)),

  //                     value: item.seriesName
  //                   });
  //                 });
  //             }
  //           }
  //         }
  //         this.screenList = newA;
  //         console.log("newA", newA);
  //       }
  //     },
  //     deep: true
  //   }
  // },
  mounted() {
    window.addEventListener("scroll", this.handleScroll, true);
  },
  beforeDestroy() {
    window.removeEventListener("scroll", this.handleScroll, true);
  },
  methods: {
    handleClick() {},
    // 获取免责声明
    getDisclaimers(disclaimerLocation, key = "disclaimerContent") {
      this.$getHttp("/api/mobile/public/getDisclaimersByDisclaimerLocation", {
        disclaimerLocation
      }).then(res => {
        if (res.code == 200) {
          this[key] = res.Disclaimers.disclaimerContent;
        }
      });
    },
    handleScroll() {
      let scrolltop =
        document.documentElement.scrollTop || document.body.scrollTop;
      scrolltop > 30 ? (this.showToTop = true) : (this.showToTop = false);
    },
    toTop() {
      let top = document.documentElement.scrollTop || document.body.scrollTop;
      // 实现滚动效果
      const timeTop = setInterval(() => {
        document.body.scrollTop = document.documentElement.scrollTop = top -= 50;
        if (top <= 0) {
          clearInterval(timeTop);
        }
      }, 10);
    },
    clg(log) {
      console.log(log);
    },
    //停止页面滚动
    stopMove() {
      let m = function(e) {
        e.preventDefault();
      };
      document.body.style.overflow = "hidden";
      document.addEventListener("touchmove", m, { passive: false }); //禁止页面滑动
    },
    //开启页面滚动
    Move() {
      let m = function(e) {
        e.preventDefault();
      };
      document.body.style.overflow = ""; //出现滚动条
      document.removeEventListener("touchmove", m, { passive: true });
    },
    // 展示违规
    showWeigui(item) {
      this.bUserId = item.userId;
      this.businessType = item.userInfo
        ? item.userInfo.businessType || ""
        : item.businessType || "";
      console.log("itemitemitemitemitem", item);
      setTimeout(() => {
        this.$refs.inform.getReportMyRecord();
      }, 100);
    },
    // shopdetails(item)
    // toAgent(item)
    shopdetails(item) {
      if (item.distributor) {
        this.$router.push({
          path: "/index/newDealerDetails",
          query: {
            id: item.distributor.id
          }
        });
      } else {
        this.$message({
          message: "个人车源！",
          type: "error",
          offset: 120,
          duration: 2000
        });
      }
    },
    toAgent(item) {
      // if (item.userInformation && item.userInformation.isAgent == 0) {
      //   this.$router.push({
      //     path: "/index/userDetail",
      //     query: {
      //       id: item.publisherId
      //     }
      //   });
      //   return;
      // }
      this.$router.push({
        path: "/index/goldConsultant",
        query: {
          id: item.publisherId || item.userId
          // userId:item.userId,
        }
      });
    },
    // 协议
    toXieyi(id) {
      window.open(
        "https://www.bangbangtongcheng.com/conven_pc/#/index/particulars?type=prot&id=" +
          id,
        "_blank"
      );
    },
    chatzc(id, aid, chattype, index) {
      localStorage.setItem("chatType", chattype || 2);
      this.$refs.chats.chatOpne(id, aid, index);
    },
    chatcz(id, aid, chattype, index) {
      // this.chatcz(this.tHouseInfo.userInfo.id,this.tHouseInfo.id)
      localStorage.setItem("chatType", chattype || 2);
      this.$refs.chats.chatOpne(id, aid, index);
    },
    // 插入电话记录
    insertCallRecord(param) {
      if (this.insertCallRecordLoading) return;
      this.insertCallRecordLoading = true;
      this.$postHttp("/api/mobile/public/increaseCallRecord", {
        userId: JSON.parse(localStorage.getItem("userInfo")).id,
        businessType: param.businessType,
        telephoneNumber: param.phone || param.telephoneNumber,
        associationId: param.associationId||this.$route.query.id|| param.userId,
        callType: param.callType
      }).then(res => {
        this.insertCallRecordLoading = false;
      });
    },
    // 委托发布
    delegate(i) {
      this.$router.push({
        path: "/my/bbcz/commissionRental",
        query: {
          type: "add",
          index: i || 1
        }
      });
    },
    // 去我
    toUser(loginstate) {
      if (localStorage.getItem("userInfo")) {
        //查询最新用户信息
        this.$getHttp("/mob/login/getUserInfoByPhone", {
          phone: JSON.parse(localStorage.getItem("userInfo")).phone
        }).then(data => {
          if (data.code == 200) {
            localStorage.setItem("userInfo", JSON.stringify(data.userInfo));
          }
        });
        this.$router.push("/my/bbcz/wdRelease");
        // this.$router.push("/my/bbcz/bbczpersonal");
      } else {
        this.$message({
          message: "请登录！",
          type: "error",
          offset: 120,
          duration: 2000
        });
      }
    },
    //处理图片
    manageImg(imgs) {
      if (!imgs) return [];
      var arr = [];
      if (null != imgs && imgs != "") {
        if (imgs.indexOf("|") == -1) {
          if (imgs != "") {
            arr.push(imgs);
            console.log("imgs", arr);
            return arr;
          } else {
            return [];
          }
        } else {
          return imgs.split("|");
        }
      }
      return [];
    },
    // recover(target, source) {
    //   if (target === undefined || target === null) {
    //     throw new TypeError("Cannot convert first argument to object");
    //   }
    //   var to = Object(target);
    //   if (source === undefined || source === null) {
    //     return to;
    //   }
    //   var keysArray = Object.keys(Object(target));
    //   for (
    //     var nextIndex = 0, len = keysArray.length;
    //     nextIndex < len;
    //     nextIndex++
    //   ) {
    //     var nextKey = keysArray[nextIndex];
    //     var desc = Object.getOwnPropertyDescriptor(target, nextKey);
    //     if (desc !== undefined && desc.enumerable) {
    //       if (to.hasOwnProperty(nextKey)) {
    //         if (to[nextKey] instanceof Array) {
    //           to[nextKey] = source[nextKey];
    //         } else if (to[nextKey] instanceof Object) {
    //           recover(to[nextKey], source[nextKey]);
    //         } else if (source[nextKey] !== undefined) {
    //           to[nextKey] = source[nextKey];
    //         } else if (typeof to[nextKey] === "string") {
    //           to[nextKey] = "";
    //         } else {
    //           to[nextKey] = undefined;
    //         }
    //       }
    //     }
    //   }
    //   return to;
    // },

    /**
     * 表单对象赋值:
     * 对目标对象存在且源对象同样存在的属性，全部覆盖；
     * 目标对象不存在但是源对象存在的属性， 全部丢弃；
     * 目标对象存在但是源对象不存在的属性，保留目标对象的属性不做处理
     */
    // recoverNotNull(target, source) {
    //   if (target === undefined || target === null) {
    //     throw new TypeError("Cannot convert first argument to object");
    //   }
    //   var to = Object(target);
    //   if (source === undefined || source === null) {
    //     return to;
    //   }
    //   var keysArray = Object.keys(Object(target));
    //   for (
    //     var nextIndex = 0, len = keysArray.length;
    //     nextIndex < len;
    //     nextIndex++
    //   ) {
    //     var nextKey = keysArray[nextIndex];
    //     var desc = Object.getOwnPropertyDescriptor(target, nextKey);
    //     if (desc !== undefined && desc.enumerable) {
    //       if (to.hasOwnProperty(nextKey)) {
    //         if (to[nextKey] instanceof Array) {
    //           to[nextKey] = source[nextKey];
    //         } else if (to[nextKey] instanceof Object) {
    //           recover(to[nextKey], source[nextKey]);
    //         } else if (source[nextKey] !== undefined) {
    //           to[nextKey] = source[nextKey];
    //         }
    //       }
    //     }
    //   }
    //   return to;
    // },
    myErrorMessage(title) {
      this.$message({
        message: title,
        type: "error",
        offset: 120,
        duration: 2000
      });
    },
    mySuccessMessage(title) {
      this.$message({
        message: title,
        type: "success",
        offset: 120,
        duration: 2000
      });
    },
    goVehicleAgentDetails(item) {
      // if(item'该账户已注销')
      if (
        (item.userInformation &&
          (item.userInformation.delFlag == 1 ||
            item.userInformation.nikeName == "该账户已注销" ||
            item.delFlag == 1)) ||
        item.delFlag == 1
      ) {
        this.myErrorMessage("该用户已注销");
        return;
      }

      // if (!item.isAgent && !item.storeId) {
      //   this.$router.push({
      //     path: "/index/userDetail",
      //     query: {
      //       id: item.publisherId || item.id
      //     }
      //   });
      //   return;
      // }

      this.$router.push({
        path: "/index/goldConsultant",
        query: {
          id: item.publisherId || item.id
        }
      });
    },
    // 职位detail
    goHouseAgentDetails(item) {
      if (
        (item.userInformation && item.userInformation.delFlag == 1) ||
        item.delFlag == 1
      ) {
        this.myErrorMessage("该用户已注销");
        return;
      }

      // if (!item.isAgent && !item.shopId) {
      //   this.$router.push({
      //     path: "/index/userDetail",
      //     query: {
      //       id: item.user_id || item.userId || item.id
      //     }
      //   });
      //   return;
      // }
      this.$router.push({
        path: "/index/goldConsultant",
        query: {
          id: item.user_id || item.userId || item.publisherId || item.id
        }
      });
    },
    goVehicleShopDetails(item) {
      if (item.distributor) {
        if (item.deleteFlag == 1) {
          this.myErrorMessage("该店铺已注销");
          return;
        }
        this.$router.push({
          path: "/index/newDealerDetails",
          query: {
            id: item.distributor.id
          }
        });
      } else {
        this.$message({
          message: "个人车源！",
          type: "error",
          offset: 120,
          duration: 2000
        });
      }
    },
    goHouseShopDetails(item) {
      if (
        (item.shop_name == "个人房源" || !item.shopInfo) &&
        !item.shopId &&
        !item.shop_id
      ) {
        this.$message({
          message: "个人房源！",
          type: "error",
          offset: 120,
          duration: 2000
        });
      } else {
        if (item.isDelUser == 0) {
          this.myErrorMessage("该店铺已不存在");
          return;
        }
        const routeLink = this.$router.resolve({
          path: "/index/ShopDetails?id=" + (item.shop_id || item.shopId)
        });
        window.open(routeLink.href, "_blank");
        // this.$router.push({
        //   path: "/index/ShopDetails",
        //   query: {
        //     id: item.shop_id
        //   }
        // });
      }
    },
    goVehicleDetails(item) {
      if (item.shelfStatus == 0 || item.deleteFlag == 1) {
        this.$message({
          message: "该车源已不存在或已下架",
          type: "error",
          offset: 120,
          duration: 2000
        });
        return;
      }
      this.$router.push({
        path: "/index/newSourceDetails",
        query: {
          id: item.id
        }
      });
    },
    goHouseDetails(item) {
      if (item.delFlag == 1 || item.upStatus == 0 || item.status == 1) {
        this.$message({
          message: "该房源已不存在或已租售",
          type: "error",
          offset: 120,
          duration: 2000
        });
        return;
      }
      // 二手房
      if (item.transactionType == 1) {
        this.$router.push({
          path: "/index/leaseDetails",
          query: {
            id: item.id
          }
        });
      } else {
        // 新房
        this.$router.push({
          path: "/index/newHouseDetails",
          query: {
            id: item.id
          }
        });
      }
    },
    // 招聘的紧急人
    agentDetailNew(item) {
      this.openUrlb("/index/goldConsultant", {
        id:
          (item.userInformation && item.userInformation.id) ||
          (item.userInformationDto && item.userInformationDto.id) ||
          item.publisherId ||
          item.id ||
          ""
      });
    },
    // 跳转公司
    companyDetails(item) {
      console.log(item);
      this.openUrlb("inviteCompany", {
        userId:
          (item.userInformation && item.userInformation.id) ||
          (item.userInformationDto && item.userInformationDto.id) ||
          item.publisherId||
          ""
      });
    },
    // 去简历
    goResumeOne(param = {}, item = {}) {
      var curPageUrl = window.location.href;
      let func = "";
      if (
        curPageUrl.indexOf("my") > -1 &&
        curPageUrl.indexOf("my/bbcz/wdRelease") == -1
      ) {
        if (
          item.deleteFlag == 1 ||
          item.shelfStatus == 0 ||
          (!item.userInformation &&
            item.recruitmentInformationDTO &&
            !item.recruitmentInformationDTO.userInformation)
        ) {
          this.myErrorMessage("该简历信息已删除");
          return;
        }
        func = "openUrls";
      } else {
        func = "openUrlb";
      }
      this[func]("/invite/resumeOne", param);
    },
    // 去职位
    goInviteDetail(param = {}, item = {}) {
      var curPageUrl = window.location.href;
      let func = "";
      if (
        curPageUrl.indexOf("my") > -1 &&
        curPageUrl.indexOf("my/bbcz/wdRelease") == -1
      ) {
        func = "openUrls";
        if (
          item.deleteFlag == 1 ||
          item.shelfStatus == 0 ||
          (!item.userInformation &&
            item.biographicalNotesDTO &&
            !item.biographicalNotesDTO.userInformation)
        ) {
          this.myErrorMessage("该招聘信息已下架");
          return;
        }
      } else {
        func = "openUrlb";
      }
      this[func]("/invite/invitedetail", param);
    },
    replaceN(param){
      return (param||'').replace(/[(\n)]+/g, '<br/>')
    },
    // 返回
    backClose(){

      const vm = this
      const originRoute = { ...vm.$route }
      vm.$router.back()
      // Of course, we must detect until a $nextTick is reached
      vm.$nextTick(() => {
        // If the route is not changed, we do the redirect
        if (this.isEqual(originRoute,vm.$route)) {
          // Redirect to the home path by default
          // console.log('页面未跳转')
        }
      })
    },
    isEqual(obj1, obj2) {
      function isObject(obj) {
        return typeof obj === 'object' && obj !== null
    }

      // 如果其中没有对象
      if (!isObject(obj1) || !isObject(obj2)) {
        //值类型
          return obj1 === obj2
      }
      // 如果特意传的就是两个指向同一地址的对象
      if (obj1 === obj2) {
          return true
      }
      // 两个都是对象或者数组，而且不相等
      // 拿到对象key
      let obj1Keys = Object.keys(obj1)
      let obj2Keys = Object.keys(obj2)
          // 先判断长度就可以过滤一些
      if (obj1Keys.length !== obj2Keys.length) {
          return false
      }
      // 以obj1为基准 和 obj2 一次递归比较
      for (let key in obj1) {
          // 递归比较当前每一项
          const res = this.isEqual(obj1[key], obj2[key])
          // 如果碰到一个不一样的就返回 false
          if (!res) {
              // 跳出for循环
              return false
          }
      }
      // 否则全相等
      return true
  },
    getType(param) {
      // es6中null的类型为object
      if (param === null) {
        return param + "";
      }
      if (typeof param === "object") {
        let val = Object.prototype.toString.call(param).split(" ")[1];
        let type = val.substr(0, val.length - 1).toLowerCase();
        return type;
      } else {
        return typeof param;
      }
    },
    openUrl(url, type = "_blank", query = {},option) {
      /* type 从self 改为_blank  甲方提要新页面打开，加上旧方法会有不更新视图，但是需要处理的页面实在太多了，所以openUrl全局改为新页面打开 */
      var reg = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
      let route;
      if (typeof url != "object" && !reg.test(url)) {

        if (url.indexOf("/") > -1) {
          route = this.$router.resolve({
            path: url, //这里是跳转页面的path
            query
          });
        // console.log('urlurlurlurlP')

        } else {
          route = this.$router.resolve({
            name: url, //这里是跳转页面的name
            query
          });
        // console.log('urlurlurlurlN',route.href)

        }

      }else{

        route = this.$router.resolve(url);
        // console.log('route',route)
      }
        console.log('route',route)
        // return

      url=route.href
      window.open(url, type);
    },
    openUrlb(url, query = {},option={}) {
      this.openUrl(url, "_blank", query,option);
    },
    openUrls(url, query = {},option={}) {
      this.openUrl(url, "_self", query,option);
    },
    // 检查登录
    checkLogin(callback, slience = false, tip = "请先登录！") {
      let user = JSON.parse(localStorage.getItem("userInfo"));
      if (user) {
        callback && callback(user);
        return true;
      } else {
        if (!slience) {
          this.myErrorMessage(tip);
        }
        return false;
      }
    },
    //停止页面滚动
    stopMove() {
      let m = function (e) {
        e.preventDefault();
      };
      document.body.style.overflow = "hidden";
      document.addEventListener("touchmove", m, { passive: false }); //禁止页面滑动
    },
    //开启页面滚动
    Move() {
      let m = function (e) {
        e.preventDefault();
      };
      document.body.style.overflow = ""; //出现滚动条
      document.removeEventListener("touchmove", m, { passive: true });
    },
    // this.addIntegral(5,'关注帮友圈')
    // this.addIntegral(5,"收藏车源");
    // this.addIntegral(5,"收藏房源");
    // this.addIntegral(5,"关注用户");
    // this.addIntegral(5,"收藏用户");
    // this.addIntegral(5,"收藏门店")
    // this.addIntegral(6,'点赞')
    // 增加帮帮豆
    addIntegral(val, title) {
      var obj = { ruleNumber: val };
      if (title) obj.title = title;
      this.$postHttp("/mob/iteration/addIntegral", {
        userId: JSON.parse(localStorage.getItem("userInfo")).id,
        ...obj
      }).then(res => {});
    },
    // dealObjFnc(key, value, type) {
    //   if (type == "set") {
    //     // var brandIdToVehicleSeriesId = JSON.parse(
    //     //   JSON.stringify(this.brandIdToVehicleSeriesId)
    //     // );
    //     // console.log(JSON.stringify(this.brandIdToVehicleSeriesId, null, 2));
    //     if (typeof value != "string") {
    //       value = JSON.parse(JSON.stringify(value));
    //       console.log("value.brandName", value);
    //       if (value.brandName) {
    //         //如果是品牌
    //         if (this.brandIdToVehicleSeriesId[key]) {
    //           //如果当前品牌存在
    //           if (
    //             this.brandIdToVehicleSeriesId[key].findIndex(
    //               item => item.uuid && item.uuid == value.id
    //             ) > -1
    //           ) {
    //             //如果当前品牌id存在
    //             return this.dealObjFnc(key, value, "get");
    //           }
    //           // 上面判断可无
    //           return this.dealObjFnc(key, value, "get");
    //         }

    //         value.uuid = value.id;
    //         value.id = "";
    //         console.log("value.brandName", value);
    //       } else {
    //         //不然就是车系
    //       }
    //     }
    //     console.log(
    //       "22222222222222222",
    //       this.brandIdToVehicleSeriesId[value.id]
    //     );
    //     if (!this.brandIdToVehicleSeriesId[key]) {
    //       // this.brandIdToVehicleSeriesId = Object.assign(
    //       //   brandIdToVehicleSeriesId,
    //       //   {
    //       //     [key]: [value]
    //       //   }
    //       // );
    //       this.brandIdToVehicleSeriesId[key] = [value];
    //     } else if (this.brandIdToVehicleSeriesId[key]) {
    //       console.log("123");
    //       if (
    //         this.brandIdToVehicleSeriesId[key].findIndex(
    //           item => item.id == value.id
    //         ) == -1
    //       ) {
    //         this.brandIdToVehicleSeriesId[key].push({ ...value });
    //       } else {
    //         var i = this.brandIdToVehicleSeriesId[key].findIndex(
    //           item => item.id == value.id
    //         );
    //         this.brandIdToVehicleSeriesId[key].splice(i, 1);
    //       }
    //     }
    //     return this.dealObjFnc(key, value, "get");
    //   }
    //   if (type == "get") {
    //     var brandIdToVehicleSeriesId = JSON.parse(
    //       JSON.stringify(this.brandIdToVehicleSeriesId)
    //     );
    //     this.brandIdToVehicleSeriesId = Object.assign(
    //       {},
    //       brandIdToVehicleSeriesId
    //     );
    //     var arr = [];
    //     var tempArr;
    //     var tempStr;
    //     var flag = false;
    //     console.log(
    //       "this.brandIdToVehicleSeriesIdthis.brandIdToVehicleSeriesId",
    //       this.brandIdToVehicleSeriesId,
    //       value
    //     );
    //     for (const key in this.brandIdToVehicleSeriesId) {
    //       tempArr = this.brandIdToVehicleSeriesId[key];
    //       console.log("tempArr", tempArr);
    //       tempStr = tempArr.filter(item => item.uuid)[0].brandName;
    //       flag = tempArr.filter(item => !item.uuid).length > 0;

    //       arr = arr.concat(
    //         tempArr
    //           .map(item => {
    //             if (item.uuid) {
    //               return !flag ? item.brandName : "";
    //             } else {
    //               return tempStr + "|" + item.seriesName;
    //             }
    //           })
    //           .filter(item => item)
    //       );
    //     }
    //     console.log("arr", arr);

    //     // brandIdToVehicleSeriesId[value.id]&&brandIdToVehicleSeriesId[value.id].filter(item=>item.id).length>0
    //     return arr;
    //   }
    //   if (type == "del") {
    //     //( this.ppaiData.id, -1, "del")
    //     if (value == -1) {
    //       //清除这品牌所有车系时
    //       let brandArr = [];
    //       let brandArrLen = 0;
    //       if (Array.isArray(this.brandIdToVehicleSeriesId[key])) {
    //         brandArr = this.brandIdToVehicleSeriesId[key].filter(
    //           item => item.uuid
    //         );
    //         brandArrLen = brandArr.length;
    //       }

    //       this.brandIdToVehicleSeriesId[key] = brandArr;
    //     } else {
    //       var index = Array.isArray(this.brandIdToVehicleSeriesId[key])
    //         ? this.brandIdToVehicleSeriesId[key].findIndex(
    //             item => item.id == value.id
    //           )
    //         : -1;
    //       if (index > -1) {
    //         //清除这品牌单个车系时
    //         this.brandIdToVehicleSeriesId[key].splice(index, 1);
    //       } else {
    //         //这品牌增加单个车系时
    //         this.dealObjFnc(key, value, "set");
    //       }
    //     }
    //     return this.dealObjFnc(key, value, "get");
    //   }
    //   if (type == "del1") {
    //     delete this.brandIdToVehicleSeriesId[key];
    //     return this.dealObjFnc(key, value, "get");
    //   }
    //   if (type == "delAll") {
    //     //所有
    //     this.brandIdToVehicleSeriesId = {};
    //     return [];
    //   }
    // },
    getElementToPageTop(el) {
      if (el.parentElement) {
        return this.getElementToPageTop(el.parentElement) + el.offsetTop;
      }
      // this.clg(el.offsetTop)
      return el.offsetTop;
    },
    getDiffElementToTop(targetEl) {
      return Math.abs(
        document.documentElement.scrollTop - this.getElementToPageTop(targetEl)
      );
    },
    scrollToElement(targetEl) {
      // document.body.scrollTop = document.documentElement.scrollTop = 0
      this.clg(this.getElementToPageTop(targetEl));
      // setTimeout(() => {
      document.body.scrollTop = document.documentElement.scrollTop = this.getElementToPageTop(
        targetEl
      );
      // }, 200)
    },
    formatTime(fmt, timestamp) {
      var date = new Date(timestamp); // 兼容safari
      var o = {
        "M+": date.getMonth() + 1,
        "d+": date.getDate(),
        "h+": date.getHours(),
        "m+": date.getMinutes(),
        "s+": date.getSeconds(),
        "q+": Math.floor((date.getMonth() + 3) / 3),
        S: date.getMilliseconds()
      };
      if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(
          RegExp.$1,
          (date.getFullYear() + "").substr(4 - RegExp.$1.length)
        );
      }
      for (var k in o) {
        if (new RegExp("(" + k + ")").test(fmt)) {
          fmt = fmt.replace(
            RegExp.$1,
            RegExp.$1.length === 1
              ? o[k]
              : ("00" + o[k]).substr(("" + o[k]).length)
          );
        }
      }
      return fmt;
    },
    async authUser(auth) {
      var user = localStorage.getItem("userInfo")
        ? JSON.parse(localStorage.getItem("userInfo"))
        : null;
      if (user) {
        var data = await this.$getHttp("/mob/login/getUserInfoByPhone", {
          phone: user.phone
        });
        if (data.code == 200) {
          localStorage.setItem("userInfo", JSON.stringify(data.userInfo));
          var flag = this.rolePermissions(data.userInfo, auth);
          if (!flag) {
            this.myErrorMessage("操作异常，您的身份已发生改变，请关闭当前页面");
          }
          return flag;
        }
      } else {
        this.myErrorMessage("请登录！");
      }
    },
    rolePermissions(user, auth) {
      // 卖房  租房  卖新车 卖旧车 帮友圈
      var authList = [];
      if (!user.businessType || user.businessType == "0") {
        //普通人
        // , "经纪人认证", "销售顾问认证", "房产店铺", "汽车店铺"
        authList = ["卖房", "租房", "卖旧车", "帮友圈"];
      } else if (user.businessType == 1) {
        if (user.isShop == 0 && user.shopType == 1) {
          //房商家经纪人
          authList = ["卖房", "租房", "帮友圈"];
        }
        if (user.isShop == 0 && user.shopType == 2) {
          //楼盘经纪人
          // authList = ["帮友圈"]
        } else if (user.isShop == 1 && user.shopType == 1) {
          //房商家
          authList = ["卖房", "租房", "帮友圈", "房轮播"];
        } else if (user.isShop == 1 && user.shopType == 2) {
          //楼盘
          authList = ["楼盘", "帮友圈"]; //发布楼盘没校验
        }
      } else if (user.businessType == 2) {
        if (user.isShop == 0 && (user.shopType == 1 || user.shopType == 2)) {
          //车商家经纪人
          authList = ["卖新车", "卖旧车", "帮友圈"];
        }
        if (user.isShop == 0 && (user.shopType == 3 || user.shopType == 3)) {
          //车服务商家经纪人
          authList = ["服务项目", "帮友圈"];
        } else if (
          user.isShop == 1 &&
          (user.shopType == 1 || user.shopType == 2)
        ) {
          //车商家
          authList = ["卖新车", "卖旧车", "帮友圈", "车系", "车轮播"];
        } else if (
          user.isShop == 1 &&
          (user.shopType == 3 || user.shopType == 4)
        ) {
          //车服务商家
          authList = ["服务项目", "帮友圈", "车轮播"];
        }
      }
      // this.clg(authList)
      return authList.includes(auth);
    },
    async userfy(item) {
      if (!this.checkLogin()) {
        return;
      }
      let yy = await this.getjjr(item.id);
      if (yy.businessType == 1 && yy.shopType == 2 && yy.isShop == 1) {
        // if (!yy.buildingId) {
        //   this.myErrorMessage("该商家还未发布楼盘！");
        //   return;
        // }

        this.openUrlb("/index/storeyDetails", {
          id: yy.buildingId
        });
        return;
      }
      if (yy.businessType == 1 && yy.shopType == 1 && yy.isShop == 1) {
        this.openUrlb("/index/ShopDetails", {
          id: yy.shopId,
          tabNum: 4
        });
        return;
      }
      if (
        yy.businessType == 2 &&
        (yy.shopType == 1 || yy.shopType == 2) &&
        yy.isShop == 1
      ) {
        this.openUrlb("/index/newDealerDetails", {
          id: yy.shopId,
          tabNum: 5
        });

        return;
      }
      if (
        yy.businessType == 2 &&
        (yy.shopType == 3 || yy.shopType == 4) &&
        yy.isShop == 1
      ) {
        this.openUrlb("/index/ownerServiceDetails", {
          id: yy.shopId,
          tabNum: 4
        });

        return;
      }
      if (!yy.businessType && yy.enterpriseRecruitmentStatus == 1) {
        this.openUrlb("/invite/company", {
          id: yy.id
        });

        return;
      }

      this.openUrlb("/index/goldConsultant", {
        id: item.id,
        tabNum: 10
      });
    },
    async getjjr(id) {
      let that = this;
      let data = {};
      await this.$getHttp("/api/mobile/public/getPersonalHome", {
        otherId: id,
        ownerId: this.user.id
      }).then(res => {
        data = res.personalHomeData;
      });
      return data;
    }
  }
};
